package leetcode_2501_2600;

public class LeeCode_2522 {
    public static void main(String[] args) {
        System.out.println(minimumPartition("165462", 60));
    }
    private static int minimumPartition(String s, int k) {
        int len = s.length(), i = 0, ans = 0;
        while (i < len){
            int j = i + 1;
            while (j <= len){
                long num = Long.parseLong(s.substring(i, j));
                if (num > k){
                    j--;
                    break;
                }
                j++;
            }
            if (j == len + 1){
                ans++;
                break;
            }
            if (j == i)
                return -1;
            ans++;
            i = j;
        }
        return ans;
    }
}
